package com.linkwechat.wecom.client;

import com.dtflys.forest.annotation.*;
import com.linkwechat.wecom.domain.dto.*;
import com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor;
import com.linkwechat.wecom.interceptor.WeAppAccessTokenInterceptor;
import com.linkwechat.wecom.interceptor.WeProViderAccessTokenInterceptor;
import com.linkwechat.wecom.retry.WeCommonRetryWhen;

/**
 * 应用管理相关接口
 */
@BaseRequest(baseURL = "${weComServerUrl}${weComePrefix}", interceptor = WeAppAccessTokenInterceptor.class)
@Retry(maxRetryCount = "3", maxRetryInterval = "1000", condition = WeCommonRetryWhen.class)
public interface WeAppClient {

    /**
     * 获取企业应用列表
     * @return {@link WeAppDto}
     */
    @Request(url = "/agent/list")
    WeAppDto  findAgentList();



    /**
     * 根据应用id获取应用详情,first
     * @param agentid 应用id
     * @return {@link WeAppDetailDto}
     */
    @Request(url = "/agent/get")
    WeAppDetailDto  findAgentById(@Query("agentid") String agentid,@Header("firstsecret")String secret);

    /**
     * 根据应用id获取应用详情
     * @param agentid 应用id
     * @return {@link WeAppDetailDto}
     */
    @Request(url = "/agent/get")
    WeAppDetailDto  findAgentById(@Query("agentid") String agentid);

    /**
     * 设置应用
     * @param weAppDetailDto {@link WeAppDetailDto}
     * @return {@link WeResultDto}
     */
    @Request(url = "/agent/set",type = "POST")
    WeResultDto updateAgentById(@JSONBody WeAppDetailDto weAppDetailDto,@Header("agentid")String agentid);




    /**
     * 获取登录用户信息(扫码),服务商
     * @param auth_code
     * @return
     */
    @Request(url = "/service/get_login_info",
            type = "POST",interceptor = WeProViderAccessTokenInterceptor.class
    )
    WeLoginUserInfoDto getLoginInfo(@JSONBody("auth_code") String auth_code);


    /**
     * 获取访问用户身份(内部应用) 没有找到接口
     * @param code
     * @param agentId 应用的id,请求头中
     * @return
     */
    @Deprecated
    @Request(url = "/user/getuserinfo")
    WeUserInfoDto  getuserinfo(@Query("code")String code,@Header("agentId")String agentId);
}
